import re
#替换


user_info = {"username":"12288889999","pwd":"12345678"}
pattern = r"#(.*?)#"
my_string  = '{"username":"*phone*","pwd":"*pwd*"}'
def replace_label(target):
    pattern = r"#(.*?)#"
    while re.search(pattern, target):
        key = re.search(pattern, target).group(1)  #第一个参数匹配到
        value = user_info[key]
        target = re.sub(pattern,value,target,1)
    return target


print(replace_label(my_string))